#pragma once

namespace winboost {
   namespace detail {

struct draw_utils
{
   template<typename T> static void init_struct(T* pstruct);

   static Gdiplus::RectF rectf_from_rct(RECT& rect);
   static Gdiplus::Rect rect_from_rct(RECT& rect);

   static LONG height(RECT& rect);
   static LONG width(RECT& rect);

   static void screen_to_client(HWND hwnd, LPRECT prect);
};

//-------------------------------------
// Implementation
//-------------------------------------
inline Gdiplus::RectF draw_utils::rectf_from_rct(RECT& rect)
{
   Gdiplus::RectF rectF;
   rectF.X = static_cast<Gdiplus::REAL>(rect.left);
   rectF.Y = static_cast<Gdiplus::REAL>(rect.top);
   rectF.Width = static_cast<Gdiplus::REAL>(rect.right - rect.left);
   rectF.Height = static_cast<Gdiplus::REAL>(rect.bottom - rect.top);
   return rectF;

}

inline Gdiplus::Rect draw_utils::rect_from_rct(RECT& rect)
{
   Gdiplus::Rect rc;
   rc.X = rect.left;
   rc.Y = rect.top;
   rc.Width = rect.right - rect.left;
   rc.Height = rect.bottom - rect.top;
   return rc;
}

template<typename T> void draw_utils::init_struct(T* pstruct)
{
   ZeroMemory(pstruct, sizeof(T));
}

inline LONG draw_utils::height(RECT& rect)
{
   return rect.bottom - rect.top;
}

inline LONG draw_utils::width(RECT& rect)
{
   return rect.right - rect.left;
}

inline void draw_utils::screen_to_client(HWND hwnd, LPRECT prect)
{
   ::ScreenToClient(hwnd, (LPPOINT)prect);
   ::ScreenToClient(hwnd, ((LPPOINT)prect)+1);
}

   }
}

